using Assets.Pixelation.Example.Scripts;
using UnityEngine;

namespace Assets.Pixelation.Scripts
{
	[ExecuteInEditMode]
	[AddComponentMenu("Image Effects/Color Adjustments/Pixelation")]
	public class Pixelation : ImageEffectBase
	{
		[Range(64f, 640f)]
		public float BlockCount = 128f;

		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			float aspect = Camera.main.aspect;
			Vector2 vector = new Vector2(BlockCount, BlockCount / aspect);
			Vector2 vector2 = new Vector2(1f / vector.x, 1f / vector.y);
			base.material.SetVector("BlockCount", vector);
			base.material.SetVector("BlockSize", vector2);
			Graphics.Blit(source, destination, base.material);
		}
	}
}
